package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/*
 *@Description:
 *@author:刘哥
 *@Date:17:46 2022/7/14
 */
@RestController
@RequestMapping("/users")
//@CrossOrigin("域名")
public class UserController {
    @GetMapping("")
    public List<User> findAll(){
        List<User> users=new ArrayList<User>();
        users.add(new User(1,"tom","123456","admin"));
        users.add(new User(2,"jack","123456","admin"));
        users.add(new User(3,"amy","123456","admin"));
        return users;
    }
    @DeleteMapping("/{id}")
    public String deleteById(@PathVariable("id") Integer id){
        System.out.println("id = " + id);
        return "success";
    }
    @PutMapping("")
    public String update(@RequestBody User user){
        System.out.println("user = " + user);
        return "success";
    }

    @PostMapping("")
    public String insert(@RequestBody User user){
        System.out.println("user = " + user);
        return "success";
    }

}
